#
# Author: Joao Tavanez n.3109    
# #Date: 21/04/2011
#
#

import model
import wx


# Rebides09 link
URL09 = 'http://www.rebides.oces.mctes.pt/Rebides09/rebid_m1.asp?CodR='



class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        
        # Menu Bar
        self.frame_1_menubar = wx.MenuBar()
        self.File = wx.Menu()
        self.Close = wx.MenuItem(self.File, 4, "Close", "", wx.ITEM_NORMAL)
        self.File.AppendItem(self.Close)
        self.frame_1_menubar.Append(self.File, "File")
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu_sub = wx.Menu()
        wxglade_tmp_menu_sub.Append(5, "Nr of teachers per year", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu_sub.Append(6, "Nr of teachers per institution", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu_sub.Append(7, "Nr of teachers per degree", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendMenu(wx.NewId(), "Teachers", wxglade_tmp_menu_sub, "")
        wxglade_tmp_menu_sub = wx.Menu()
        wxglade_tmp_menu_sub.Append(9, "Institutions per year", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu_sub.Append(10, "Institutions/Establishments per year", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendMenu(wx.NewId(), "Institutions", wxglade_tmp_menu_sub, "")
        wxglade_tmp_menu_sub = wx.Menu()
        wxglade_tmp_menu_sub.Append(11, "Holders of degree per year", "", wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendMenu(wx.NewId(), "Degree", wxglade_tmp_menu_sub, "")
        self.frame_1_menubar.Append(wxglade_tmp_menu, "Statistics")
        self.SetMenuBar(self.frame_1_menubar)
        # Menu Bar end

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.evt_Close, self.Close)
        self.Bind(wx.EVT_MENU, self.evt_teachers_year, id=5)
        self.Bind(wx.EVT_MENU, self.evt_teachers_institution, id=6)
        self.Bind(wx.EVT_MENU, self.evt_teachers_degree, id=7)
        self.Bind(wx.EVT_MENU, self.evt_instit_year, id=9)
        self.Bind(wx.EVT_MENU, self.evt_instit_estab, id=10)
        self.Bind(wx.EVT_MENU, self.evt_holders_degree, id=11)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("frame_1")
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade
    
    
    def evt_Close(self, event): # wxGlade: MyFrame.<event_handler>
        exit(0)
        event.Skip()

    def evt_teachers_year(self, event): # wxGlade: MyFrame.<event_handler>
        data = model.teachers_year()
        
        message = " They are " + str(data[0]) + " Teachers in 2000 " \
            + "\n\n They are " + str(data[1] - data[0]) + " Teachers in 2001" \
            + "\n\n They are " + str(data[2] - data[1]) + " Teachers in 2002" \
            + "\n\n They are " + str(data[3] - data[2]) + " Teachers in 2003" \
            + "\n\n They are " + str(data[4] - data[3]) + " Teachers in 2004" \
            + "\n\n They are " + str(data[5] - data[4]) + " Teachers in 2005" \
            + "\n\n They are " + str(data[6] - data[5]) + " Teachers in 2006" \
            + "\n\n They are " + str(data[7] - data[6]) + " Teachers in 2007" \
            + "\n\n They are " + str(data[8] - data[7]) + " Teachers in 2008" \
            + "\n\n They are " + str(data[9] - data[8]) + " Teachers in 2009" 
                    
        wx.MessageBox(message, 'Total of Teachers per Year')
        pass

    def evt_teachers_institution(self, event): # wxGlade: MyFrame.<event_handler>
        
        teacher_insti = model.teachers_institution()
        
        message = " They are " + str(teacher_insti[0]) + " Teachers in Ensino Sup. Pub. Militar e Policial " \
            + "\n\n They are " + str(teacher_insti[1]) + " Teachers in Ens. Sup. Part. e Coop. Univ." \
            + "\n\n They are " + str(teacher_insti[2]) + " Teachers in Ens. Sup. Publico Politecnico" \
            + "\n\n They are " + str(teacher_insti[3]) + " Teachers in Ens. Sup. Publico Universitario" \
            + "\n\n They are " + str(teacher_insti[4]) + " Teachers in Ens. Sup. Part. e Coop. Poli" \
            + "\n\n They are " + str(teacher_insti[5]) + " Teachers in Ens. Privado Universitario" \
            + "\n\n They are " + str(teacher_insti[6]) + " Teachers in Ens. Privado Politecnico"
       
                        
        wx.MessageBox(message, 'Information about 2000 Year')
          
        pass


    def evt_teachers_degree(self, event): # wxGlade: MyFrame.<event_handler>
        teacher_deg = model.teachers_degree()
        
        message = " They are " + str(teacher_deg[0]) + " Teachers with Licenciatura " \
            + "\n\n They are " + str(teacher_deg[1]) + " Teachers with Mestrado" \
            + "\n\n They are " + str(teacher_deg[2]) + " Teachers with Doutoramento"
            
        wx.MessageBox(message, 'Teachers Degree in 2009')


    def evt_instit_year(self, event): # wxGlade: MyFrame.<event_handler>
        data = model.instit_year()
        
        message = " They are " + str(data[0]) + " Institutions in 2000 " \
            + "\n\n They are " + str(data[1]) + " Institutions in 2001 " \
            + "\n\n They are " + str(data[2]) + " Institutions in 2002 " \
            + "\n\n They are " + str(data[3]) + " Institutions in 2003 " \
            + "\n\n They are " + str(data[4]) + " Institutions in 2004 " \
            + "\n\n They are " + str(data[5]) + " Institutions in 2005 " \
            + "\n\n They are " + str(data[6]) + " Institutions in 2006 " \
            + "\n\n They are " + str(data[7]) + " Institutions in 2007 " \
            + "\n\n They are " + str(data[8]) + " Institutions in 2008 " \
            + "\n\n They are " + str(data[9]) + " Institutions in 2009 " 
            
        wx.MessageBox(message, 'List of Institutions')

    def evt_instit_estab(self, event): # wxGlade: MyFrame.<event_handler>
        print "Event handler `evt_instit_estab' not implemented"
        event.Skip()

    def evt_holders_degree(self, event): # wxGlade: MyFrame.<event_handler>
        print "Event handler `evt_instit_estab' not implemented"
        event.Skip()
        

# end of class MyFrame


if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()
